JAVAC=javac
JAR=jar
CP=cp
CD=cd
RM=rm -rf
JAVAC_FLAGS=-source 1.3 -target 1.3

APP_NAME=TMain
BROWSER_NAME=TBrowser
MAIN_MENU=TMainMenu
APP_FILES=${APP_NAME}.java ${BROWSER_NAME}.java ${MAIN_MENU}.java

WTK_PATH=/home/dima/Tools/WTK2.5.2
WTK_LIB_PATH=${WTK_PATH}/lib
WTK_BIN_PATH=${WTK_PATH}/bin

PREVERIFY=${WTK_BIN_PATH}/preverify

CLDAPI_PATH=${WTK_LIB_PATH}/cldcapi11.jar
MIDPAPI_PATH=${WTK_LIB_PATH}/midpapi21.jar
JSR75API_PATH=${WTK_LIB_PATH}/jsr75.jar

CLASS_PATH=-classpath ${CLDAPI_PATH}:${MIDPAPI_PATH}:${JSR75API_PATH}:.

STAFF_DIR=staff
ICON=icon.png
JAD=${APP_NAME}.jad
MANIFEST=Manifest.mf
RESOURCES=${STAFF_DIR}/${ICON}
RESOURCES+=${STAFF_DIR}/${MANIFEST}
RESOURCES+=${STAFF_DIR}/${JAD}

RES_FILES=${APP_NAME}.class
RES_FILES+=${BROWSER_NAME}.class
RES_FILES+=${MAIN_MENU}.class

BUILD_DIR=./output/

all:
	${JAVAC} ${JAVAC_FLAGS} ${CLASS_PATH} ${APP_FILES}
	${PREVERIFY} ${CLASS_PATH} ${APP_NAME} ${BROWSER_NAME} ${MAIN_MENU} -d {BUILD_DIR}
	${CP} ${RESOURCES} ${BUILD_DIR}
	${CD} ${BUILD_DIR}
	${JAR} -cvfm ${APP_NAME}.jar ${MANIFEST} ${ICON} ${RES_FILES}

clean:
	-${RM} ${RES_FILES}
	-${RM} ${BUILD_DIR}/